
#pragma once

const std::string RELOAD_DEBUGER_CONFIG_FILE_NAME = "ReloadDebuger.xml";

#define RELOAD_DEBUG_WAIT_RESPONSE_SECONDS 5

class ReloadDebugerAppConfigure : public asyframe::ConfigureBase
{
public:
	ReloadDebugerAppConfigure();
	virtual ~ReloadDebugerAppConfigure();

	virtual retT init(const std::string _configFileName=DEFAULT_CONFIG_FILE_NAME);

	std::string instanceName_;
	unsigned short debugPort_;
};

class ReloadDebugerApp : public asyframe::AppBase, public virtual asyframe::IUdpAction
{
public:
	ReloadDebugerApp(asyframe::ConfigureBase* _pConfigure = new asyframe::ConfigureBase());
	virtual ~ReloadDebugerApp();

	virtual retT initInstance(int argc, char* argv[]);

	virtual retT init();
	virtual retT start();

	retT parseCmd(boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	retT onSendCmd( boost::shared_ptr<asyframe::UdpHandlerContext> _pUdpHandlerContext, std::size_t _bytesTransferred, const boost::system::error_code& e, std::size_t _timeoutCount);
	retT onReadReloadDebugResponse( boost::shared_ptr<asyframe::UdpHandlerContext> _pUdpHandlerContext, std::size_t _bytesTransferred, const boost::system::error_code& e, std::size_t _timeoutCount);
	retT parseChordInfo(boost::shared_ptr<asyframe::IoBuffer> _pBuffer);
	retT parseDataStorageInfo(boost::shared_ptr<asyframe::IoBuffer> _pBuffer);

protected:
	boost::shared_ptr<asyframe::UdpHandler> pUdpHandler_;
	int cmd_;
	boost::shared_ptr<boost::asio::ip::udp::endpoint> pRemoteEndpoint_;
};
